#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int halveArray(vector<int>& nums) {
        priority_queue<double> heap;
        double sum = 0;
        for (auto x : nums)
        {
            heap.push(x);
            sum += x;
        }
        sum = sum / 2.0;
        int ret = 0;
        while (sum > 0)
        {
            double t = heap.top() / 2.0;
            heap.pop();
            sum -= t;
            ret++;
            heap.push(t);
        }
        return ret;
    }
};